GtkSpinButton: Always emit value-changed when the adjustment is changed
authorDebarshi Ray <debarshir@gnome.org>
Tue, 12 Aug 2014 11:44:34 +0000 (13:44 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 14 Aug 2014 03:42:11 +0000 (23:42 -0400)
commit1e304e6debd9045fbe2c7ba01865e7ea2dbff22b
treeb49f80cf3003d45598a57036db032852eebce0ef
parenta0faf5a51ced242985e993abc2bc6684863564e0
GtkSpinButton: Always emit value-changed when the adjustment is changed

Changing adjustment via the property setter would not emit
value-changed, however changing it via gtk_spin_button_configure would.

This inconsistency had the following side-effects:

  - Setting an adjustment with a different value would not update the
    value shown by the spin button.

  - Creating a spin button like this (common in GtkBuilder XML) will
    not show the initial value:
      g_object_new (GTK_TYPE_SPIN_BUTTON, "adjustment", adj, NULL);

Let's use the same code path (ie. gtk_spin_button_configure) for all
public facing API for setting adjustment. The code that handled the
details of swapping out the old adjustment with the new has been split
into an unset_adjustment method and the rest has been folded into
gtk_spin_button_configure.

A spin button really needs an adjustment to work, so we don't need
most of the NULL checks. However we do need to check in
unset_adjustment because setting a new adjustment during object
creation might try to unset a non-existent one.

https://bugzilla.gnome.org/show_bug.cgi?id=734660
gtk/gtkspinbutton.c